<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
    <title>用户管理</title>
    <meta name="decorator" content="default"/>
    <script type="text/javascript">
        $(document).ready(function() {
            $("#no").focus();
            $("#inputForm").validate({
                rules: {
                    loginName: {remote: "${ctx}/sys/user/checkLoginName?oldLoginName=" + encodeURIComponent('${user.loginName}')}
                },
                messages: {
                    loginName: {remote: "用户登录名已存在"},
                    confirmNewPassword: {equalTo: "输入与上面相同的密码"}
                },
                submitHandler: function(form){
                    loading('正在提交，请稍等...');
                    form.submit();
                },
                errorContainer: "#messageBox",
                errorPlacement: function(error, element) {
                    $("#messageBox").text("输入有误，请先更正。");
                    if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
                        error.appendTo(element.parent().parent());
                    } else {
                        error.insertAfter(element);
                    }
                }
            });
        });
    </script>
</head>
<body>
<ul class="nav nav-tabs">
    <li><a href="${ctx}/sys/user/list">用户列表</a></li>
    <li class="active">
        <a href="${ctx}/sys/user/form?id=${user.id}">用户
            <shiro:hasPermission name="sys:user:edit">${not empty user.id?'修改':'添加'}</shiro:hasPermission>
            <shiro:lacksPermission name="sys:user:edit">查看</shiro:lacksPermission>
        </a>
    </li>
</ul>
<br/>
<form:form id="inputForm" modelAttribute="reportConfigIn" action="${ctx}/report/configIn/save" method="post" class="form-horizontal">
    <sys:message content="${message}"/>
    <form:hidden path="inConditionId"/>
    <form:hidden path="reportId"/>

    <div class="control-group">
        <label class="control-label">参数编码:</label>
        <div class="controls">
            <form:input path="itemCode" htmlEscape="false" maxlength="50" class="required"/>
            <span class="help-inline"><font color="red">*</font> </span>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">参数名称:</label>
        <div class="controls">
            <form:input path="itemName" htmlEscape="false" maxlength="50" class="required"/>
            <span class="help-inline"><font color="red">*</font> </span>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">参数类型:</label>
        <div class="controls">
            <form:select path="itemType" class="required input-medium" onchange="changeShow(this.value)">
                <form:option value="">请选择</form:option>
                <form:options items="${fns:getDictList('REPORT_CONFIGIN_ITEMTYPE')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
            </form:select>
            <span class="help-inline"><font color="red">*</font> </span>
        </div>
    </div>
    <div class="control-group" id="check">
        <label class="control-label">参数限制类型:</label>
        <div class="controls" id="checkType1" style="display:none">
            <input name="checkType" htmlEscape="false" maxlength="4000" readonly="readonly" class="w-input262"/>
            <span class="help-inline"><font color="red">*</font>不需要填写任何值</span>
        </div>
        <div  class="controls" id="checkType2" style="display:none">
            <textarea name="checkType" htmlEscape="false" class="input-n3 w-input262 h60">
                <c:if test="${reportConfigIn.itemType eq '2' }">${reportConfigIn.checkType}</c:if>
            </textarea>
            <span class="help-inline">0,xxxxx;1,yyyyy 形式</span>
        </div>
        <div  class="controls" id="checkType3" style="display:none">
            <form:select path="checkType" class="input-medium required">
                <form:option value="">请选择</form:option>
                <form:options items="${fns:getDictList('REPORT_CONFIGIN_ITEMTYPE')}" htmlEscape="false"/>
            </form:select>
        </div>
        <div  class="controls" id="checkType4" style="display:none">
             <textarea name="checkType" htmlEscape="false" class="input-n3 w-input262 h60">
                <c:if test="${reportConfigIn.itemType eq '4' }">${reportConfigIn.checkType }</c:if>
            </textarea>
            <span class="help-inline"><font color="red">*</font>select aaa as label,bbb as value from c 形式</span>
        </div>
        <div  class="controls" id="checkType5" style="display:none">
            <form:select path="checkType" class="input-medium">
                <form:option value="yyyy-MM-dd">yyyy-MM-dd</form:option>
                <form:option value="yyyy-MM-dd HH:mm:ss">yyyy-MM-dd HH:mm:ss</form:option>
            </form:select>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">参数初始值:</label>
        <div class="controls">
            <form:input path="initialValue" htmlEscape="false" class="required"/>
            <span class="help-inline"><font color="red">*</font> </span>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">备注：</label>
        <div class="controls">
            <form:textarea path="remark" htmlEscape="false" rows="3" maxlength="200" class="input-xlarge"/>
            <span class="help-inline"><font color="red">*</font> </span>
        </div>
    </div>
    <div class="form-actions">
        <shiro:hasPermission name="report:configIn:edit">
            <input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;
        </shiro:hasPermission>
        <input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
    </div>
</div>
</form:form>

<script src="${ctxStatic}/jquery-validation/1.11.0/jquery.validate.min.js" type="text/javascript"></script>
<script type="text/javascript">
    $(function(){
        var itemType = $("#itemType").val();
        changeShow(itemType);
        $("#inputForm").validate({
            submitHandler: function (form) {
                $("#loadingDiv").show();
                var iType = $("#itemType").val();
                if (iType == '0' || iType == '1') {
                    $("#check > div[id!='checkType1']").remove();
                } else if (iType == '2') {
                    $("#check > div[id!='checkType2']").remove();
                } else if (iType == '3') {
                    $("#check > div[id!='checkType3']").remove();
                } else if (iType == '4') {
                    $("#check > div[id!='checkType4']").remove();
                } else if (iType == '5') {
                    $("#check > div[id!='checkType5']").remove();
                }
                form.submit();
            },
            errorContainer: "#messageBox",
            errorPlacement: function (error, element) {
                $("#messageBox").text("输入有误，请先更正。");
                if (element.is(":checkbox") || element.is(":radio") || element.parent().is(".input-append")) {
                    error.appendTo(element.parent().parent());
                } else {
                    error.insertAfter(element);
                }
            }
        });
    });
    function changeShow(val) {
        $("#check > div").hide();
        if (val == '0' || val == '1') {
            $("#checkType1").show();
        } else if (val == '2') {
            $("#checkType2").show();
        } else if (val == '3') {
            $("#checkType3").show();
        } else if (val == '4') {
            $("#checkType4").show();
        } else if (val == '5') {
            $("#checkType5").show();
        }
    }
</script>
</body>
</html>